package com.cuicuisha.gxyp.manager.service.impl;

import com.cuicuisha.gxyp.manager.mapper.SysRoleUserMapper;
import com.cuicuisha.gxyp.manager.service.SysRoleUserService;
import com.cuicuisha.gxyp.model.dto.system.AssginRoleDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ClassName: SysRoleUserServiceImpl
 * Description:
 *
 * @Author 脆脆鲨
 * @Create 2024-09-13 17:27
 * @Version 1.0
 */
@Service
public class SysRoleUserServiceImpl implements SysRoleUserService {

    @Autowired
    private SysRoleUserMapper sysRoleUserMapper;

    @Transactional
    @Override
    public void doAssign(AssginRoleDto assginRoleDto) {

        sysRoleUserMapper.deleteByUserId(assginRoleDto.getUserId());
        List<Long> roleIdList = assginRoleDto.getRoleIdList();
        if (roleIdList.size()>0){
            sysRoleUserMapper.saveUserRole(assginRoleDto);
        }
    }
}
